package com.yunji.cabinet.provide;

import com.yunji.base.bo.ChangeBindBO;
import com.yunji.cabinet.bo.*;
import com.yunji.cabinet.business.CabinetBusiness;
import com.yunji.cabinet.domain.ContainerCell;
import com.yunji.cabinet.domain.ContainerDO;
import com.yunji.cabinet.service.ICabinetCellService;
import com.yunji.cabinet.service.ICabinetService;
import com.yunji.cabinet.service.impl.DeviceService;
import com.yunji.cabinet.vo.CellProductCountVO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.cabinet.provide
 * @Title: CabinetProvide
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-10-26 10:02:22      V1.0        HuaAo       新建类
 */
@Component
public class CabinetProvide {

    @Resource
    ICabinetService cabinetService;

    @Resource
    ICabinetCellService cabinetCellService;

    @Resource
    CabinetBusiness cabinetBusiness;

    @Resource
    DeviceService deviceService;

    public List<CellProductCountVO> countCellProduct(Long belongId) {
        return cabinetCellService.countCellProduct(belongId);
    }

    public List<ContainerCell> getCabinetCellByCabinetId(Long cabinetId) {
        return cabinetCellService.searchByContainerId(cabinetId);
    }

    public CabinetBO selectCabinet(CabinetSelectQueryBo bo) {
        return cabinetService.select(bo);
    }

    public CabinetBO selectCabinet(Long containerId) {
        return cabinetService.select(containerId);
    }


    public void changeCabinetAgent(ChangeBindBO bo) {
        cabinetService.changeAgent(bo);
    }

    public List<CabinetBO> searchList(CabinetListQueryBO bo) {
        return cabinetService.searchList(bo);
    }

    public ContainerDO getCabinetByQrcode(String qrCode) {
        return cabinetService.getByQrcode(qrCode);
    }

    public boolean containerExistsSiteLocation(List<Long> locationIds) {
        return cabinetService.containerExistsSiteLocation(locationIds);
    }

    public void updateCabinetCell(Integer productNums, Integer ordinal, Long containerId, int i) {
        cabinetBusiness.updateCabinetCell(productNums,ordinal,containerId,i);
    }

    public void handleTissueCell(Long belongId, ContainerCell cell) {
        cabinetBusiness.handleTissueCell(belongId,cell);
    }

//    public void setEventData(OrderDO order) {
//        WipeDeviceInfoBO infoBO = deviceService.getDeviceInfoBO(order.getOrderCode());
//        if (infoBO != null) {
//            WipeDeviceInfoDTO beforeDeviceInfo = infoBO.getBeforeDeviceInfo();
//            WipeDeviceInfoDTO afterDeviceInfo = infoBO.getAfterDeviceInfo();
//            if (beforeDeviceInfo != null) {
//                order.setBeforeHeight(CabinetCache.getHeight(order.getChipImei()).intValue() - beforeDeviceInfo.getDistance());
//            }
//            if (afterDeviceInfo != null) {
//                order.setAfterProductNums(order.getBeforeProductNums() - order.getProductNums());
//            }
//        }
//    }
}